﻿using System.Web.Mvc;
using Smarly.Web.Areas.Study.Controllers;
using Smarly.Web.RouteConstraints;

namespace Smarly.Web.Areas.Study
{
	public class StudyAreaRegistration : AreaRegistration
	{
		public override string AreaName
		{
			get
			{
				return "Study";
			}
		}

		private const string subdomain = "study";

		public override void RegisterArea(AreaRegistrationContext routes)
		{

			#region Account

			routes.MapRoute(
				"Study_SignInAccountDialog",
				"dialog/account",
				new { controller = "Account", action = "Index", subdomain = subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Study_CreateAccountDialog",
				"dialog/account/create",
				new { controller = "Account", action = "Create", subdomain = subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Study_RepearAccountDialog",
				"dialog/account/repear",
				new { controller = "Account", action = "Repear", subdomain = subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Study_UpdateAccountDialog",
				"dialog/account/update/{hashcode}",
				new { controller = "Account", action = "UpdatePassword", hashcode = UrlParameter.Optional, subdomain = subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Study_SignOutAccount",
				"account/logout",
				new { controller = "Account", action = "Logout", subdomain = subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			#endregion
			routes.MapRoute(
					"Study_default",
					"",
					new { controller = "Home", action = "Index", subdomain = subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(HomeController).Namespace }
				);
		}
	}
}
